<?php

/**
 * ChiffreAffaire form base class.
 *
 * @method ChiffreAffaire getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseChiffreAffaireForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                      => new sfWidgetFormInputHidden(),
      'date'                    => new sfWidgetFormInputHidden(),
      'montant_chiffre_affaire' => new sfWidgetFormInputText(),
      'date_chiffre_affaire'    => new sfWidgetFormInputHidden(),
      'id_client'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'add_empty' => true)),
      'id_fournisseur'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'add_empty' => true)),
      'id_representant'         => new sfWidgetFormInputText(),
      'created_at'              => new sfWidgetFormDateTime(),
      'updated_at'              => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'date'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('date')), 'empty_value' => $this->getObject()->get('date'), 'required' => false)),
      'montant_chiffre_affaire' => new sfValidatorNumber(array('required' => false)),
      'date_chiffre_affaire'    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('date_chiffre_affaire')), 'empty_value' => $this->getObject()->get('date_chiffre_affaire'), 'required' => false)),
      'id_client'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Client'), 'required' => false)),
      'id_fournisseur'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'required' => false)),
      'id_representant'         => new sfValidatorInteger(array('required' => false)),
      'created_at'              => new sfValidatorDateTime(),
      'updated_at'              => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('chiffre_affaire[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'ChiffreAffaire';
  }

}
